package cn.dota2info.elk.user.controller;


import cn.dota2info.elk.user.entity.RolesInfo;
import cn.dota2info.elk.user.entity.UserInfo;
import cn.dota2info.elk.user.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;

import java.util.Collections;

@RestController
public class UserController {

    @Autowired
    UserInfoService service;

    @RequestMapping(value = "login",method = RequestMethod.POST)
    public Mono login(@RequestBody UserInfo userInfo){
        return service.login(userInfo.getName(),userInfo.getPassword());
    }
    @RequestMapping(value = "/user/info")
    @ResponseBody
    public RolesInfo getUserRole(){
       RolesInfo rolesInfo=new RolesInfo();
       rolesInfo.setRoles(Collections.singletonList("admin"));
       rolesInfo.setName("管理员");
       rolesInfo.setIntroduction("这是个描述");
       return rolesInfo;
    }
}
